#!/bin/bash

aclocal --version &>/dev/null || {
  echo
  echo "**Error**: You must have \`aclocal' installed to compile this package."
  exit 1
}

autoheader --version &>/dev/null || {
  echo
  echo "**Error**: You must have \`autoconf' installed to compile this package."
  exit 1
}

if [ `uname` == "Darwin" ]; then
  glibtoolize --version &>/dev/null || {
    echo
    echo "**Error**: You must have \`glibtool' installed to compile this package."
    exit 1
  }
else
  libtoolize --version &>/dev/null || {
    echo
    echo "**Error**: You must have \`libtool' installed to compile this package."
    exit 1
  }
fi

automake --version &>/dev/null || {
  echo
  echo "**Error**: You must have \`automake' installed to compile this package."
  exit 1
}

autoconf --version &>/dev/null || {
  echo
  echo "**Error**: You must have \`autoconf' installed to compile this package."
  exit 1
}

touch NEWS ChangeLog README

echo "aclocal..."
aclocal &>/dev/null || exit 1

echo "autoheader..."
autoheader &>/dev/null || exit 1

if [ `uname` == "Darwin" ]; then
  echo "glibtoolize..."
  glibtoolize --force --copy &>/dev/null || exit 1
else
  echo "libtoolize..."
  libtoolize --force --copy &>/dev/null || exit 1
fi

echo "automake..."
automake --copy --gnu --add-missing &>/dev/null || exit 1

echo "autoconf..."
autoconf &>/dev/null || exit 1

rm -rf autom4te.cache &>/dev/null

echo "Bye :)"
